<?php
declare(strict_types=1);

namespace app\validate;

class MerchantValidate extends BaseValidate
{
    protected $rule = [
        'username'      => 'require|length:4,20',
        'password'      => 'require|length:6,20',
        'merchant_name' => 'require|length:2,50',
        'merchant_type' => 'require|in:1,2',
        'contact_name'  => 'require|length:2,20',
        'contact_phone' => 'require|mobile',
        'email'         => 'require|email',
    ];

    protected $message = [
        'username.require'      => '用户名不能为空',
        'username.length'       => '用户名长度必须在4-20个字符之间',
        'password.require'      => '密码不能为空',
        'password.length'       => '密码长度必须在6-20个字符之间',
        'merchant_name.require' => '商家名称不能为空',
        'merchant_name.length'  => '商家名称长度必须在2-50个字符之间',
        'merchant_type.require' => '商家类型不能为空',
        'merchant_type.in'      => '商家类型不正确',
        'contact_name.require'  => '联系人姓名不能为空',
        'contact_name.length'   => '联系人姓名长度必须在2-20个字符之间',
        'contact_phone.require' => '联系电话不能为空',
        'contact_phone.mobile'  => '联系电话格式不正确',
        'email.require'         => '邮箱不能为空',
        'email.email'           => '邮箱格式不正确'
    ];

    // 登录场景
    public function sceneLogin(): MerchantValidate
    {
        return $this->only(['username', 'password']);
    }

    // 注册场景
    public function sceneRegister(): MerchantValidate
    {
        return $this->only(['username', 'password', 'merchant_name', 'merchant_type', 'contact_name', 'contact_phone', 'email']);
    }
} 